package com.owg.jigsaw;

public class WPointerBlock extends WBlockBase
{
	public final WBlockBase referenceBlock;
	
	public WPointerBlock(WBlockBase referenceBlock)
	{
		super(referenceBlock.getRoot(), referenceBlock.tabType.get().getKey(), false, referenceBlock.color.get());
		referenceBlock.destructionListeners.addActionListener((e) -> 
		{
			if(blockContainer().get() != null)
				blockContainer().get().getChildren().remove(this);
			dispose();
		});
		this.referenceBlock = referenceBlock;
	}
	@Override
	public WBlock makePointerBlock()
	{
		throw new IllegalArgumentException("Cannot create pointer block from a pointer block...");
	}
	@Override
	public WBlock copy(boolean withChildren)
	{
		return new WPointerBlock(referenceBlock);
	}
	@Override
	protected void addNotify2()
	{
		getRoot().pointerBlockAdded(this);
	}
	@Override
	protected void removeNotify2()
	{
		getRoot().pointerBlockRemoved(this);
	}
}
